package com.heima.behavlor.controller.v1;

import com.heima.behavlor.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @package com.heima.behavlor.controller.v1
 * @Date 2022/3/8
 * @project heima-leadnews
 */
@Api(value = "用户行为管理",tags = "用户行为管理")
@RestController
@RequestMapping("/api/v1")
public class behaviorController {
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    private ApReadBehaviorService apReadBehaviorService;
    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation("点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }
    @ApiOperation("阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }
    @ApiOperation("不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unlikesbehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }
    @ApiOperation("收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collectionbehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }
    @ApiOperation("查询文章行为")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult load_articlebehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
